package service.impl;

import bean.User;
import dao.impl.UserDaoImpl;
import service.UserService;

public class UserServiceImpl implements UserService {
    
    private UserDaoImpl userDao = new UserDaoImpl();

    @Override
    public boolean registerUser(User user) {

        if(existsUserId(user.getUserCode())){
            return false;
        }

        return userDao.insertUser(user) > 0;
    }

    @Override
    public boolean existsUserId(String userId) {
        return userDao.queryUserByUserId(userId) != null;
    }

    @Override
    public User login(String userId,String password) {
        return userDao.queryUserByUserIdAndPassword(userId,password);
    }
}
